package com.haozi.reggie.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.stereotype.Component;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

@Data
@Component
@Validated
@ConfigurationProperties(prefix = "servers")
public class ServerConfig {
    private String idAddress;
    @Max(value = 99,message = "最大支持99")
    private int timeout;
    private String password;
    @DurationUnit(ChronoUnit.HOURS)
    private Duration serverTimeOut;
    @DataSizeUnit(DataUnit.GIGABYTES)
    private DataSize dataSize;
}
